/*
 * Hyuga: A Density-Grid Stream Clustering Platform.
 * Copyright (C) 2014 PUC-Rio/Laboratory for Advanced Collaboration
 *
 * Hyuga is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Hyuga is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Hyuga.  If not, see <http://www.gnu.org/licenses/>.
 */
package br.pucrio.inf.lac.konoha.hyuga.command;

import org.apache.log4j.Logger;

import com.espertech.esper.client.EPServiceProvider;

import br.pucrio.inf.lac.konoha.hyuga.core.Output;

/**
 * Command for resetting the engine output base time. Useful for synchronizing and resetting a distributed deploy. 
 * 
 * @author Marcos Roriz <mroriz@inf.puc-rio.br>
 */
public class ResetCommand extends Command {
    
    // Logger
    private static Logger LOGGER = Logger.getLogger(ResetCommand.class.getCanonicalName());

    public ResetCommand(String commandSTR) {
        super(commandSTR);
    }
    
    public ResetCommand(String commandSTR, EPServiceProvider cepEngine) {
        super(commandSTR, cepEngine);
    }

    @Override
    public void execute() {
        Output output = Output.getInstance();
        output.clear();
        output.setup();
        
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Cleaned the Output queue and resetted the output time to 0.");
        } else {
            System.out.println("Cleaned the Output queue and resetted the output time to 0.");
        }
    }
}
